package cn.batch.daemon;

/**
 *  征信数据装载，处理错误后，从本地重新导入程序。
 */
import java.text.ParseException;
import java.util.Date;

import cn.batch.daemon.loadBatch.LoadProcReportFromLocal;
import cn.batch.daemon.util.DateUtil;

public class LoadProcFileFromLocalMain {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		if (args.length < 1) {
			throw new IllegalArgumentException("请传入需要加载的数据日期字符串。格式: yyyyMMdd");
		}
		
		Date bDate = null;
		try {
			bDate = DateUtil.fromString(args[0], "yyyyMMdd");
		} catch (ParseException e) {
			throw new IllegalArgumentException("参数格式无效。格式：yyyyMMdd");
		}
		
		int runDays = 1;
		if (args.length == 2) {
			try {
				runDays = Integer.parseInt(args[1]);
			} catch (NumberFormatException e) {
				throw new IllegalArgumentException("参数格式无效。第二个参数请输入数字。");
			}
		}
		
		Configuration config = new Configuration();
		LoadProcReportFromLocal loader = new LoadProcReportFromLocal(config);
		loader.setBatchDate(bDate);
		loader.setRunDays(runDays);
		loader.run();
		System.exit(0);
	}

}
